<?php


namespace app\home\controller;


use app\home\services\MessageService;
use app\utils\Response;

class MessageController extends ApiBase
{
    public function getList()
    {
        $pageData = [
            'page' => (int)$this->requestData['page'],
            'pageSize' => (int)$this->requestData['page_size'],
        ];
        $messageService = new MessageService();
        $messageList = $messageService->getList($pageData, ['id', 'title', 'create_time']);
        Response::success([
            'message_list' => $messageList
        ]);
    }

    public function getInfo()
    {
        $id = (int)$this->requestData['id'];
        if ($id <= 0) {
            Response::fail("id异常");
        }
        $messageService = new MessageService();
        $info = $messageService->getInfoById($id, ['id', 'create_time', 'title', 'describe']);
        $info['create_time'] = date("Y-m-d H:i:s", $info['create_time']);
        Response::success([
            'info' => $info
        ]);
    }
}